package com.hcb.tonguetiphealth.model;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import com.hcb.tonguetiphealth.util.StringUtils;

import android.database.Cursor;

public class User extends AbstractTask{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int id;
	private String userId;//用户id
	private String userName = "";//用户名
	private String passWord = "";//密码
	private String imgUrl;//头像地址
	private String sex;//性别
	private String labels;//标签
	private String info;//简介
	private float level; //健康合理指数 
	private String area; //地区
	private String fans;//粉丝
	private String attention;//关注
	private String groupId;// groupId = 8 为公司;	groupId = 5 为个人
	private long loginTime = 0;
	private int rememb = 0;
	private int autoLogin = 0;
	private boolean isLogin = false;//是否在线
	
	private String commentNum;

	private String height;   //身高cm
	private String weight;   //体重Kg
	private String checkedBody; //体检指示
	private long birthDayTimeInMillis; //出生年月的毫秒数
	private String realName; //昵称、真实姓名
	private String province; //省份
	private String city;     //城市
	private String eMail;    //电子邮箱
	private String tel;      //电话号码
	private String chatId;   //聊天id
	private long time;       //最近一次聊天时间 （精确到秒）
	private boolean hasNewMsg; //是否有新消息
	private String chatInfo; //聊天提示信息
	private boolean isAccepted;//对方是否已接受聊天
	
	private List<Chat> chatList;  //聊天记录
	public List<Chat> getChatList() {
		return chatList;
	}
	public void addChat(Chat chat) {
		this.chatList.add(chat);
	}
	public void addChat(List<Chat> chatList) {
		this.chatList.addAll(chatList);
	}
	public void setChatList(List<Chat> chatList) {
		this.chatList = chatList;
	}
	
	public User() {
		chatList = new ArrayList<Chat>();
	}
	public User(final Cursor mCursor) {
		chatList = new ArrayList<Chat>();
		
		if (mCursor != null && !mCursor.isClosed()) {
			id = mCursor.getInt(0);
			userName = mCursor.getString(1);
			passWord = mCursor.getString(2);
			loginTime = mCursor.getLong(3);
			rememb = mCursor.getInt(4);
			autoLogin = mCursor.getInt(5);
		}
	}
	
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUserName() {
		return formate(userName);
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassWord() {
		return formate(passWord);
	}
	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}
	public long getLoginTime() {
		return loginTime;
	}
	public void setLoginTime(long loginTime) {
		this.loginTime = loginTime;
	}
	public int getRememb() {
		return rememb;
	}
	public void setRememb(int rememb) {
		this.rememb = rememb;
	}
	public int getAutoLogin() {
		return autoLogin;
	}
	public void setAutoLogin(int autoLogin) {
		this.autoLogin = autoLogin;
	}
	
	public String toString() {
		return "id:" + id + "\nuserName:" + userName 
				+ "\npassWord:" + passWord + "\nloginTime:" + loginTime 
				+ "\nrememb:" + rememb + "\nautoLogin:" + autoLogin;
	}
	public boolean isLogin() {
		return isLogin;
	}
	public void setLogin(boolean isLogin) {
		this.isLogin = isLogin;
	}
	
	public String getImgUrl() {
		return imgUrl;
	}
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getLabels() {
		return labels;
	}
	public void setLabels(String labels) {
		this.labels = labels;
	}
	public String getInfo() {
		return info;
	}
	public void setInfo(String info) {
		this.info = info;
	}
	public Float getLevel() {
		return level;
	}
	public void setLevel(Float level) {
		this.level = level;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public String getArea() {
		return area;
	}
	public void setArea(String area) {
		this.area = area;
	}
	public String getFans() {
		return fans;
	}
	public void setFans(String fans) {
		this.fans = fans;
	}
	public String getAttention() {
		return attention;
	}
	public void setAttention(String attention) {
		this.attention = attention;
	}
	public String getGroupId() {
		return groupId;
	}
	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}
	public String getCommentNum() {
		return commentNum;
	}
	public void setCommentNum(String commentNum) {
		this.commentNum = commentNum;
	}
	public void setLevel(float level) {
		this.level = level;
	}
		public String getRealName() {
		return formate(realName);
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public String getProvince() {
		return formate(province);
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return formate(city);
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String geteMail() {
		return formate(eMail);
	}
	public void seteMail(String eMail) {
		this.eMail = eMail;
	}
	public String getTel() {
		return formate(tel);
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getChatId() {
		if(StringUtils.isEmpty(chatId)) {
			chatId = "-1";
		}
		return formate(chatId);
	}
	public void setChatId(String chatId) {
		this.chatId = chatId;
	}
	public String getChatInfo() {
		return formate(chatInfo);
	}
	public void setChatInfo(String chatInfo) {
		this.chatInfo = chatInfo;
	}
	public boolean isAccepted() {
		return isAccepted;
	}
	public void setAccepted(boolean isAccepted) {
		this.isAccepted = isAccepted;
	}
	public String getHeight() {
		return StringUtils.isEmpty(height)?"0":height;
	}
	public void setHeight(String height) {
		this.height = height;
	}
	public String getWeight() {
		return StringUtils.isEmpty(weight)?"0":weight;
	}
	public void setWeight(String weight) {
		this.weight = weight;
	}
	public String getCheckedBody() {
		return formate(checkedBody);
	}
	public void setCheckedBody(String checkedBody) {
		this.checkedBody = checkedBody;
	}
	public long getBirthDayTimeInMillis() {
		return birthDayTimeInMillis;
	}
	public void setBirthDayTimeInMillis(long birthDayTimeInMillis) {
		this.birthDayTimeInMillis = birthDayTimeInMillis;
	}
	public int getAge() {
		if(birthDayTimeInMillis == 0) {
			 return 0;
		} else {
			Calendar c = Calendar.getInstance();
			int intYear = c.get(Calendar.YEAR);
			c.setTimeInMillis(birthDayTimeInMillis);
			
			return intYear - c.get(Calendar.YEAR);
		}
	}
	public long getTime() {
		return time;
	}
	public void setTime(long time) {
		this.time = time;
	}
	public boolean isHasNewMsg() {
		return hasNewMsg;
	}
	public void setHasNewMsg(boolean hasNewMsg) {
		this.hasNewMsg = hasNewMsg;
	}

	
}
